<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>ueditor/editor_all.js"></script> 
<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8"
		src="<%=basePath%>ueditor/editor_config.js"></script>
<style>
<!--
  .check{
      margin-left:15px;
  }
-->
</style>

		<c:if test="${message }">
		  <div style="width:98%; height:50px;">
		            <strong> 添加成功</strong>
		  </div>  
		</c:if>
<form action="<%=basePath %>backend/addnews" class='form-horizontal' method="post" id='newsForm'>
			<div class="row">
              <div class="span6 control-group" style='margin-top:10px;margin-left:15px;'>
                  <label class="control-label" >类型:</label>
                  <select class="controls" style='margin-top:9px;' id='bnkind' name='bn'>
                  <option value='news'>新闻</option>
                  <option value="bulletin">公告</option>
                  </select>
                  <span></span>
               </div>
               <br/>
               <br/>
               <div class="span12 control-group" style='margin-top:10px;margin-left:15px;'>
                 <label class="control-label" >归属:</label>
                 <div id='newskind' style='margin-left:6px;margin-top:6px;' >
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check' type="checkbox"  value="0001" name='putong'>普通新闻
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check'  type="checkbox" value="0010" name='dangjian'>党建新闻
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check'   type="checkbox" value="0100" name='student'>学生新闻
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check'  type="checkbox" value="1000" name='zhaoshengjiuye'>招生就业新闻
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check'  type="checkbox" value="10000" name='keyan'>科研新闻
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check'  type="checkbox" value="100000" name='keyan'>研招新闻
                   <input id='' style='margin-left:10px;' class='checkbox1 newskind check'  type="checkbox" value="1000000" name='keyan'>教学动态
                 </div>
                 <div id='bulletinkind'  style='margin-left:6px;margin-top:6px;'>
                   <input id='' style='margin-left:10px;' class='checkbox1 bulletkind check' type="checkbox" value="0001" name='putong'>普通公告
                   <input id='' style='margin-left:10px;' class='checkbox1 bulletkind check' type="checkbox" value="0010" name='dangjian'>党建公告
                   <input id='' style='margin-left:10px;' class='checkbox1 bulletkind check' type="checkbox" value="0100" name='student'>学生公告
                   <input id='' style='margin-left:10px;' class='checkbox1 bulletkind check'  type="checkbox" value="1000" name='student'>招生就业公告
                   <input id='' style='margin-left:10px;' class='checkbox1 bulletkind check'  type="checkbox" value="10000" name='xueshu'>学术公告
                   <input id='' style='margin-left:10px;' class='checkbox1 bulletkind check'  type="checkbox" value="100000" name='xueshu'>报告讲座
                 </div>
               </div>
               <!-- Optional: clear the XS cols if their content doesn't match in height -->
               <div class="clearfix visible-xs"></div>
              
           </div>
           <div class="row div-common" style='margin-left:120px;'>
          <div class="span12 input-prepend" >
                  <label class="add-on" >标题:</label>
                 <input style='width:500px;'  type="text" name="title" >
            
              </div>
              
              </div>
              <div class="row div-common" style='margin-left:120px;'>
          <div class="span12 input-prepend" >
                  <label class="add-on" >作者:</label>
                 <input style='width:500px;'  type="text" name="reporter" >
            
              </div>
              
              </div>
              <div class="row"> 
              <label class="control-label" >内容:</label>
			  <div class='controls' style='margin-top: 10px;margin-left:170px;'>
			  
		       <script  id="editor" ></script>
		       </div>
		       </div>
	    <!-- <input type="checkbox" value="0" name='index' id='index'  />首页新闻 -->
		<input  type="submit" value="完成" style="margin-left: 700px;margin-top: 10px;" class="btn btn-info" onclick="return getContent();"/></div>
		<input id="content1" type="hidden" name="content">
		<input id='belong' name='belong' type="hidden" >
	</form>
	
	<script type="text/javascript">
	var ue = UE.getEditor('editor');
    function getContent() {
        var str= ue.getContent();
       // alert(str);
        //document.getElementById('content').value=str;
        $("#content1").val(str);
        var str="";
        var result = 0;
        if($("#bnkind").val()=="news")
        	{
        	 $(".newskind").each(function(){
             	
           	  if($(this).attr("checked") == true || $(this).attr("checked") == "checked")
   			  {
           		  str=$(this).val();
           		  result = parseInt(result,10) + parseInt(str,10);
           		  //alert(result);
   			  }
        	 });
        	}else{
        		 $(".bulletkind").each(function(){
                  	
                  	  if($(this).attr("checked") == true || $(this).attr("checked") == "checked")
          			  {
                  		  str=$(this).val();
                  		  result = parseInt(result,10) + parseInt(str,10);
                  		  //alert(result);
          			  }
               	 });
        	}
       
       
      // alert(result);
       
       
       switch(result)
       {
       case 1:
    	   result = "0001";
    	   break;
       case 10:
    	   result = "0010";
    	   break;
       case 100:
    	   result="0100";
    	   break;
       case 11:
    	   result = "0011";
    	   break;
       case 101:
    	   result = "0101";
    	   break;
       case 110:
    	   result = "0110";
    	   break;
       case 111:
    	   result = "0111";
    	   break;
       }
     //  alert(result + "--" );
       $("#belong").val(result);
      /* if($("#index").attr("checked") == true || $("#index").attr("checked") == "checked")
    	   {
    	   $(this).val(1);
    	   }*/
       result=0;
        if(document.getElementById('title').value.length==0||str.length==0)
        	{
        	  alert('还有尚未填写的内容！');
        	  document.getElementById('title').focus();
        	  return false;
        	}
        return true;
    }
</script>
